package by.bsu.scs.presentation.tabledecorator;

import org.displaytag.decorator.TableDecorator;

import by.bsu.scs.model.MarkPolicy;
import by.bsu.scs.util.manager.LocalizationManager;

/**
 * @author Alexey Hursevich
 * @version 1.0
 * 
 * Mark policy table decorator bean.
 * Gets appropriate data when displaying the the table
 * of mark policies, created by instructor. 
 * 
 */
public class MarkPolicyDecorator extends TableDecorator {
        
        private static final String EDIT_LINK_PATTERN = "<a href=\"/SCS_BSU/instructor/mark_policy.do?method=edit&policy_id=%s\">%s</a>";
        
        private final LocalizationManager loc = new LocalizationManager(MarkPolicyDecorator.class.getName());
        
        public String getName() {
                MarkPolicy mp = (MarkPolicy)getCurrentRowObject();
                return mp.getPolicyShort();
        }
        
        public String getDiscription() {
                MarkPolicy mp = (MarkPolicy)getCurrentRowObject();
                return mp.getPolicyDescription();
        }
        
        public String getEditLink() {
                MarkPolicy mp = (MarkPolicy)getCurrentRowObject();
                return String.format(EDIT_LINK_PATTERN, mp.getMarkPolicyId(), loc.getValue("edit"));
        }

}
